const secretKey = 'yucaijie'; // 密钥
const algorithm = 'aes-256-cbc'; // 加密算法
const crypto = require('crypto');
// 加密方法
function encrypt(text) {
  const cipher = crypto.createCipher(algorithm, secretKey);
  let encrypted = cipher.update(text, 'utf8', 'hex');
  encrypted += cipher.final('hex');
  return encrypted;
}

// 解密方法
function decrypt(encryptedText) {
  const decipher = crypto.createDecipher(algorithm, secretKey);
  let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
  decrypted += decipher.final('utf8');
  return decrypted;
}

module.exports = {
    encrypt,
    decrypt
}